<?php
namespace Admin\Controller;
use Common\Controller\AdminbaseController;
// +----------------------------------------------------------------------
// | Date:2016年10月17日
// +----------------------------------------------------------------------
// | Author: EK_熊<1439527494@qq.com>
// +----------------------------------------------------------------------
// | Description: 此文件作用于****
// +----------------------------------------------------------------------
class UploadFileController extends AdminbaseController{
    public function upload(){
        $upload = new \Think\Upload();// 实例化上传类    
        $upload->maxSize   =     9999999999 ;// 设置附件上传大小    
        $upload->exts      =     '';// 设置附件上传类型    
        $upload->rootPath  =       '.';
        $upload->savePath  =      '/data/upload/attachment/'; // 设置附件上传目录    
        $upload->saveName = array('uniqid','');
        $upload->replace = true;
        // 上传文件     
        $info   =   $upload->upload();  
        if(!$info) {// 上传错误提示错误信息     
            
            $data['info'] = $upload->getError();
            $data['status'] = 0;
        }else{// 上传成功        
            $data = $info;
            
            $fileId = M('file')->add([
                'created_time'=>CURRENT_TIME,
                'upload_name'=>$data['Filedata']['name'],
                'save_name'=>$data['Filedata']['savename'],
                'save_path'=>$data['Filedata']['savepath'],
                'size'=>$data['Filedata']['size'],
                'ext'=>$data['Filedata']['ext'],
                'md5'=>$data['Filedata']['md5'],
                'type'=>'article',
                'status'=>0
            ]);
            if (!$fileId) $this->ajaxReturn($data['info']);
            $data['file_id'] = $fileId;
            }
        $data['status'] = 1;
        $this->ajaxReturn($data);    
    }
    

    
   
}